package com.winit.openapi.wop.inbound.builder;

import com.alibaba.fastjson.JSONObject;
import com.winit.oms.spi.inbound.vo.InboundDispatchinfoVo;
import com.winit.openapi.util.DateUtil;
import com.winit.openapi.util.ValidateUtil;

/**
 * 海外仓入库单 提货验货构造器
 * 
 * @version <pre>
 * Author     Version       Date        Changes
 * dinghua.an   1.0         2015年11月10日     Created
 *
 * </pre>
 * @since 1.
 */
public class InboundPickupBuilder {

    /**
     * build 验货/提货信息
     * 
     * @param json
     * @return
     */
    public static InboundDispatchinfoVo buildInspectionPickUp(JSONObject json) {
        InboundDispatchinfoVo inboundDispatchinfoVo = new InboundDispatchinfoVo();
        //验货类型
        if (json.containsKey("inspectionType") && null != json.getString("inspectionType")){
        	inboundDispatchinfoVo.setInspectionType(json.getString("inspectionType").trim());
        }
        //提货类型
        if (json.containsKey("pickupType") && null != json.getString("pickupType")) {
            inboundDispatchinfoVo.setPickupType(json.getString("pickupType").trim());
        }
        //提货时间
        if (json.containsKey("reservePickupDateFrom") && json.containsKey("reservePickupDateTo")) {
            inboundDispatchinfoVo.setExpectFromDate(DateUtil.parse2Date(json.getString("reservePickupDateFrom").trim(),DateUtil.FULL_DATE_STRING));
            inboundDispatchinfoVo.setExpectToDate(DateUtil.parse2Date(json.getString("reservePickupDateTo").trim(),DateUtil.FULL_DATE_STRING));
        }
        //提货地址编码
        if (json.containsKey("pickupAddressCode") && null != json.getString("pickupAddressCode")) {
            inboundDispatchinfoVo.setAddressCode(json.getString("pickupAddressCode").trim());
        }
        //发货供应商编码
        if (json.containsKey("expressVendorCode") && null != json.getString("expressVendorCode")) {
            inboundDispatchinfoVo.setExpressVendorCode(json.getString("expressVendorCode"));
        }
        //发货供应商名称
        if (json.containsKey("expressVendorName") && null != json.getString("expressVendorName")) {
            inboundDispatchinfoVo.setExpressVendorName(json.getString("expressVendorName").trim());
        }
        //快递单号
        if (json.containsKey("expressNo") && null != json.getString("expressNo")) {
            inboundDispatchinfoVo.setExpressNo(json.getString("expressNo").trim());
        }
        return inboundDispatchinfoVo;
    }

}
